Solving 10385 - Duathlon (Ternary search)
[andmenj-acm.git] / 10295 - Hay Points / 10295.cpp
blobd20ae71a3f76decf190e6d7c61e495772c5f5d90
1 #include <map>
2 #include <iostream>
3 #include <string>
5 using namespace std;
7 int main(){
8 int words, jobs;
9 map<string, unsigned long long> dict;
10 string s;
11 unsigned long long d;
12 cin >> words >> jobs;
13 for (int i=0; i<words; ++i){
14 cin >> s >> d;
15 dict[s] = d;
18 while (jobs--){
19 unsigned long long total = 0;
20 while (cin >> s && s != "."){
21 map<string, unsigned long long>::iterator i = dict.find(s);
22 if (i != dict.end()){
23 total += i->second;
26 cout << total << endl;
28 return 0;